//
//  MJRefreshController.swift
//  SwiftTest
//
//  Created by 李江湖 on 2018/8/2.
//  Copyright © 2018年 李江湖. All rights reserved.
//

import UIKit

class MJRefreshController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    
    let btnStartTag = 1000
    let name_link_tuples = [("iphone x","9999"),
                            ("小米","555"),
                            ("三星","778"),
                            ("魅族","998"),]
    //   懒加载简写
    lazy var lable = UILabel()
    //   懒加载
    lazy var table : UITableView  = { ()->UITableView in
        let tables = UITableView(frame: CGRect(x: 0, y: 64, width: ScreenWidth, height: ScreenHeight-64), style: UITableViewStyle.plain)
        return tables
    }()
    
    //    var int : Int
    var array = [String]()
    var dict = [String : String]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        PepleTool.shareManage().name = "小明"
        PepleTool.shareManage().run()
        PepleTool.shareManage().eat()
        
        self.view!.addSubview(self.table)
        self.table.delegate = self
        self.table.dataSource = self
        self.table.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: "cell")
        // Do any additional setup after loading the view, typically from a nib.
        self.array.append("s")
        print(self.array)
        
        self.table.mj_header = JHRefreshHeaderView(refreshingBlock: {
            sleep(3)
            self.table.mj_header?.endRefreshing()
        })
        self.dict.updateValue("222", forKey: "333")
        print(self.dict)
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 10
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.name_link_tuples.count
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 100;
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let model = self.name_link_tuples[indexPath.row]
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? UITableViewCell
        cell?.textLabel?.text = model.1
        return cell!
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
